package xman.mssh.spring;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import xman.mssh.spring.aop.annotation.AnnotationPointCut;

@Component
public class SpringBeanDemo implements InitializingBean {
    static Logger logger = LoggerFactory.getLogger(SpringBeanDemo.class);
    
    public SpringBeanDemo() {
        logger.info("SpringBeanDemo initalization");
    }
    
    public void outString() {
        logger.info("+++++SpringBeanDemo+++++++++");
    }
    
    @AnnotationPointCut
    public void joinPointCut() {
        // mark this method as JoinPoint by annotationPointCut
        logger.info("+++++joinPointCut+++++++++");
    }
    
    // InitializingBean和init-method可以一起使用，Spring会先处理InitializingBean再处理init-method
    // init-method是通过反射执行的，而afterPropertiesSet是直接执行的
    public void afterPropertiesSet() throws Exception {
        logger.info("+++++++" + new Throwable().getStackTrace()[0].getMethodName() + "++++++++");
    }
    
}
